
import 'package:syn_4s/core/model/alert_event_model.dart';
import 'package:syn_4s/core/model/device_type_model.dart';
import 'package:syn_4s/core/model/heart_rate_model.dart';

class MapAllDeviceModel{
  String? id;
  String? address;
  String? deviceName;
  String? icon;
  double? lat;
  double? lng;
  int? lockStatus;
  String? lockStatusName;
  String? sn;
  int? status;
  String? statusName;
  String? tag;
  String? photo;
  String? staffName;
  String? lastAt;
  DeviceTypeModel? deviceType;
  DeviceTypeModel? alertType;
  List<AlertEventModel>? alertEvent;
  List<HeartRateModel>? baseData;

  MapAllDeviceModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    address = json['address'];
    deviceName = json['deviceName'];
    icon = json['icon'];
    lat = json['lat'];
    lng = json['lng'];
    lockStatus = json['lockStatus'];
    lockStatusName = json['lockStatusName'];
    sn = json['sn'];
    status = json['status'];
    statusName = json['statusName'];
    tag = json['tag'];
    photo = json['photo'];
    staffName = json['staffName'];
    lastAt = json['lastAt'];
    deviceType = json['deviceType'] != null ? DeviceTypeModel.fromJson(json['deviceType']) : null;
    alertType = json['alertType'] != null ? DeviceTypeModel.fromJson(json['alertType']) : null;
    if (json['alertEvent'] != null) {
      alertEvent = (json['alertEvent'] as List).map((i) => AlertEventModel.fromJson(i as Map<String,dynamic>)).toList();
    }
    if (json['baseData'] != null) {
      baseData = (json['baseData'] as List).map((i) => HeartRateModel.fromJson(i as Map<String,dynamic>)).toList();
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data['id'] = id;
    data['address'] = address;
    data['deviceName'] = deviceName;
    data['icon'] = icon;
    data['lat'] = lat;
    data['lng'] = lng;
    data['lockStatus'] = lockStatus;
    data['lockStatusName'] = lockStatusName;
    data['sn'] = sn;
    data['status'] = status;
    data['statusName'] = statusName;
    data['tag'] = tag;
    data['photo'] = photo;
    data['staffName'] = staffName;
    data['lastAt'] = lastAt;
    if (deviceType != null) {
      data['deviceType'] = deviceType!.toJson();
    }
    if (alertType != null) {
      data['alertType'] = alertType!.toJson();
    }
    if (this.alertEvent != null) {
      data['alertEvent'] = alertEvent!.map((v) => v.toJson()).toList();
    }
    if (this.baseData != null) {
      data['baseData'] = baseData!.map((v) => v.toJson()).toList();
    }
    return data;
  }

}